<html>
	<head>
		<title></title>
		<script src="./Public/jquery.11.min.js"></script>
		<script src="./Public/bt/js/bootstrap.min.js"></script>
		<link rel="stylesheet" type="text/css" href="./Public/bt/css/bootstrap.min.css"/>
		<script type="text/javascript">
		$(function() {
			$('#eee').click(function() {
		var formData = $('#fff').serialize();
		//异步
		$.ajax({
			type: "post",
			url: "index.php?c=Arc&a=add",
			data: formData,
			dataType: 'json',
			success: function(phpData) {
				var tr = '';
				tr += '<tr>';
				tr += '<td>' + phpData.id + '</td>';
				tr += '<td>' + phpData.title + '</td>';
				tr += '<td>' + phpData.content + '</td>';
				tr += '<td>' + phpData.author + '</td>';
				tr += '<td>';
				tr += '<a href="javascript:;" class="btn btn-danger dle">删除</a>';
				tr += '</td></tr>';
				$('.msg').append(tr);
				$('form')[0].reset();
			}
		})
	})

	$(document).on('click', '.dle', function() {
		var id = $(this).parents('tr').find('td').eq(0).html();
		$(this).parents('tr').remove();
		$.ajax({
			type: "post",
			url: "index.php?c=Arc&a=del",
			data: {u: id},
		})
	})

})
</script>
	</head>
	<body>
		<div class="container">
					<div class="container">
		<?php if(isset($_SESSION['username'])):
		?>
		欢迎<?php echo $_SESSION['username'] ?>回来!
			<br />
		<a href="?c=Memder&a=out">
			退出登录
		</a>
		<br />
		<?php else: ?>
		<a href="?c=Memder&a=login">
			登录
		</a>
		<br />
		<a href="?c=Memder&a=reg">
			注册
		</a>
		<?php endif ?>
		</div>
			<div class="alert alert-success" role="alert" style="margin-top: 10px">
				许愿板
			</div>
			<table class="table table-striped msg">
				<tr>
					<td>ID</td>
					<td>标题</td>
					<td>内容</td>
					<td>作者</td>
					<td> 操作 </td>
				</tr>
				<?php foreach($data as $k => $v):
				?>
				<tr>
				<td><?php echo $k ?></td>
				<td><?php echo $v['title'] ?></td>
				<td><?php echo $v['content'] ?></td>
				<td><?php echo $v['author'] ?></td>
				<td>
				<a href="javascript:;" class="btn btn-danger dle">删除</a>
				</td>
				</tr>
				<?php endforeach ?>
			</table>
			<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
			许愿
			</button>

			<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
				<div class="modal-dialog" role="document">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-label="Close">
							<span aria-hidden="true">&times;</span>
							</button>
							<h4 class="modal-title" id="myModalLabel">许愿</h4>
						</div>
						<div class="modal-body">
							<form action="javascript:;" method="post" id="fff">
								<div class="form-group">
									<label for="exampleInputEmail1">标题</label>
									<input type="text" class="form-control" id="exampleInputEmail1" name="title" required="required">
								</div>
								<div class="form-group">
									<label for="exampleInputEmail1">作者</label>
									<input type="text" class="form-control" id="exampleInputEmail1" name="author" required="required">
								</div>
								<div class="form-group">
									<label for="exampleInputPassword1">内容</label>
									<textarea name="content" id="" cols="30" rows="10" class="form-control" required="required"></textarea>
									<div class="modal-footer">
										<button type="submit" class="btn btn-info btn-block" style="margin-bottom: 20px"  data-dismiss="modal" id="eee" >
										留言
										</button>
									</div>
								</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	</body>
</html>